<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8"/>
	<meta name="baidu-site-verification" content="JdMif0g2tL" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>angular</title>
</head>
<body ng-app="myApp">
<style type="text/css" media="screen">
	*{
		margin: 0;
		padding: 0;
	}
</style>

<div ng-controller="appCtrl">
	<input type="text" ng-model="abc">
	<div repeat-num="3">
		<p ickt-bind="abc"></p>
	</div>
</div>

<script type="text/javascript">
	document.getElementsByTagName('html')[0].style.fontSize=window.screen.width/10+'px';
</script>
<script src="../js/angular.min.js" charset="utf-8"></script>
<script type="text/javascript">
	var app =angular.module('myApp', []);
	app.controller('appCtrl', ['$scope', function($scope){
		$scope.abc='hellow';
	}])
	app.directive('repeatNum', function () {
		return {
			restrict: 'A',
			template:'<div ng-repeat="item in list"><div ng-transclude></div></div>',
			transclude:true,
			controller:function($scope,$attrs){
				var num = +$attrs.repeatNum;
				// console.log(num);
				// var a=[];
				// for(var i=0;i<num;i++){
				// 	a.push(i);
				// }
				// $scope.list=a;
				// console.log($scope.list)
				$scope.list=new Array(num).fill(1).map(function(obj,index){
					return index;
				})
				console.log($scope.list)
			}
		}
	})
	app.directive('icktBind', function(){
		// Runs during compile
		return {
			restrict: 'A', // E = Element, A = Attribute, C = Class, M = Comment
			scope: {
				key:'=icktBind'
			}, // {} = isolate, true = child, false/undefined = no change
			link: function(scope, jqlite, attrs) {
				//获取父作用域中msg变量
				scope.key='hellow';
				console.log(scope.key);
				console.log(jqlite);
				console.log(attrs.icktBind)
				//监听icktBind的变化
				scope.$watch(attrs.icktBind,function(){
					jqlite.html(scope.key)
				});
				jqlite.html(scope.key)
			}
		};
	});
</script>
</body>
</html>
<!--应该是13.8，时间-2017-05-07->